package cn.dapeng.spring.core;

import java.util.Map;

/**
 * 系统启动时，把所有的单例bean，并实例化
 */
public class PreInstantiateSingleton extends DefaultBeanFactory {

    public void preInstantiateSingleton() throws Throwable {
        synchronized (this.beanDefinitionMap) {
            for (Map.Entry<String, BeanDefinition> entry : this.beanDefinitionMap.entrySet()) {
                String beanName = entry.getKey();
                BeanDefinition bd = entry.getValue();
                if (bd.isSingleton()) {
                    this.getBean(beanName);
                }
            }
        }
    }
}
